package com.xiaoma.h5testdemo.business.main.adapter

import android.util.Log
import com.bumptech.glide.Glide
import com.xiaoma.common.adapter.XmBaseBindingAdapter
import com.xiaoma.common.extend.appGlobalScope
import com.xiaoma.h5testdemo.R
import com.xiaoma.h5testdemo.common.helper.FaviconFetcher
import com.xiaoma.h5testdemo.common.models.CollectEntity
import com.xiaoma.h5testdemo.databinding.ItemWebUrlBinding
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

/**
 * author: liangjingbo
 * date: 2024/4/18
 * describe:
 */
class WebUrlAdapter:XmBaseBindingAdapter<CollectEntity,ItemWebUrlBinding> (ItemWebUrlBinding::inflate){
    override fun convert(holder: BaseBindingHolder<ItemWebUrlBinding>, data: CollectEntity, position: Int) {
        holder.binding.apply {
            tvName.text = data.tile
            appGlobalScope.launch(Dispatchers.Main.immediate){
                Glide.with(ivCon)
                    .load(data.getBitmap())
                    .error(R.drawable.ic_launcher_background)
                    .into(ivCon)
            }

        }
    }
}